<!DOCTYPE html>
<html>
<header>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<script src="assets/js/echartssg.min.js"></script>
	<script src="assets/js/vintage.js"></script>
	<script type="text/javascript" src="assets/js/jquery.min.js"></script>
	<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
	<link rel="stylesheet" href="assets/plugin/bootstrap/css/bootstrap.min.css">

	<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
	<script type="text/javascript" src="assets/plugin/bootstrap/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="assets/js/vue.min.js"></script>
	<script type="text/javascript" src="assets/js/url.min.js"></script>
	<link rel="stylesheet" type="text/css" href="assets/plugin/calendar/calendarsg.min.css">
	<script type="text/javascript" src="assets/plugin/calendar/calendar.min.js"></script>
    <script src="assets/js/layer.m/layer.m.js"></script>
	<style>
		div#iechart div canvas{top:-30px;}
		.cont{position: fixed;width: 100%;height: 100%;z-index: 999999;background-color: #000000;opacity:0.6;text-align: center; padding-top: 50px;}
		.another{display: none;}
		.cont img{width:80%;}
		.right-m{
			position: fixed;
			right: 0;
			top:45%;
			z-index: 999999;
		}
		.left-m{
			position: fixed;
			left: 0;
			top:45%;
			z-index: 999999;
		}
	</style>
	<script type="text/javascript">
		//点击开始时间框时给 id 为 ddddd 的input设值
		function setInitStartDate(){
			let tmpVal = $("#start-date").val();
			$("#tmpStartDateVal").val(tmpVal);
		}

		//layer 弹窗
		function errorBox(msg){
		    layer.open({
		        content: msg,
		        className: 'alertBg',
		        time: 2
		    });
		}
		//监听开始时间、结束时间输入框的变化，1：开始时间、2：结束时间
		function checkNewDate(valFlag){

			let today=new Date();// 日期对象
	        let year = today.getFullYear();//获取 年份
	        let month = today.getMonth() + 1;//获取 月份
	        let day = today.getDate();//获取 当前日

	        //根据年 . 月 . 日的值创建Date对象
	        let date1Obj = new Date(year,month,day);
	      	//转换为毫秒数
	        let t1 = date1Obj.getTime();


			if(valFlag == 1){
				let earliestTime = new Date(2016,1,1);//最早时间为2016年1月1号，之前的不给搜索
				let t3EarliestTime = earliestTime.getTime();
				let startTime = $("#start-date").val();
				let date2Obj = new Date(startTime.split('-')[0],startTime.split('-')[1],startTime.split('-')[2]);
	      		//转换为毫秒数
        		let t2 = date2Obj.getTime();

        		if(t2 < t3EarliestTime){
					$("#start-date").val($("#tmpStartDateVal").val());
        			errorBox('开始时间必须为2016年1月1号之后的日期！');
        			return false;
        		}
        		if(t2 > t1){
        			$("#start-date").val($("#tmpStartDateVal").val());
        			errorBox('开始时间必须小于当前时间！');
        			return false;
        		}
			}else if(valFlag == 2){
				let endTime = $("#end-date").val();
				let date2Obj = new Date(endTime.split('-')[0],endTime.split('-')[1],endTime.split('-')[2]);
	      		//转换为毫秒数
        		let t2 = date2Obj.getTime();
        		if(t2 > t1){
        			$("#end-date").val(year+'-'+month+'-'+day);
        			errorBox('结束时间时间必须小于当前时间！');
        			return false;
        		}
			}

			//开始时间不能大于结束时间
			let startTime = $("#start-date").val();
			let date2Obj1 = new Date(startTime.split('-')[0],startTime.split('-')[1],startTime.split('-')[2]);
      		//转换为毫秒数
    		let t21 = date2Obj1.getTime();

			let endTime = $("#end-date").val();
			let date2Obj2 = new Date(endTime.split('-')[0],endTime.split('-')[1],endTime.split('-')[2]);
      		//转换为毫秒数
    		let t22 = date2Obj2.getTime();
    		if(t21 > t22){
    			if(valFlag == 1){
    				$("#start-date").val($("#tmpStartDateVal").val());
    			}else{
        			$("#end-date").val(year+'-'+month+'-'+day);
    			}
        		errorBox('开始时间不能大于结束时间！');
    			return false;
    		}
		}

		let _ddoctor = {
			//请求数据接口
			apiUrl : '',

			//请求数据接口的参数
			params : {
				"startTime": getQueryString('startTime'),
 				"endTime": getQueryString('endTime') ,
 				"type": 2,
 				"actId": 1012090,
 				"patientId": getQueryString('patientId') ,
 				"sourceType": 0,
 				"isFirst":1
			},
			username : getQueryString('username') || '',
		};

		function getQueryString(name) {
     		let reg = new RegExp("(^|&)" + name +"=([^&]*)(&|$)");
     		let r = window.location.search.substr(1).match(reg);
     		if(r!=null) {
     			return  unescape(r[2]);
     		}
     		return null;
		}

		let startTime=url("?startTime")
		let endTime=url("?endTime");
		let patientId=url("?patientId");
		let urlname=url("?os");
		if(urlname=='ios'){
			window.location.href="iosindex.html?startTime="+startTime+"&endTime="+endTime+
			"&patientId="+patientId+"&os="+urlname+"isFirst=1";
		}
	</script>
	<script type="text/javascript">
		$(function(){
			$("#link").click(function(){
				$(this).addClass("another"); //在原有样式上，在叠加样式
			})
		});
	</script>
</header>

<body style="background-color:rgb(255, 255, 255);">
    <!--<img class="right-m" src="1.gif"/>-->
	<!--<img class="left-m"  src="2.gif"/>-->
	<div class="cont" id="link">
		<img src="hdts.gif"/>
	</div>
	<div id="main" class="container-fluid">
		<div class="row" style="padding-left: 20%;padding-top: 2%;">
			<div class="col-xs-5 col-md-2" style="width: 33%;">
				<div class="input-group">
				  	<input type="text" id="start-date" onmouseover="setInitStartDate()" onchange="checkNewDate(1)" v-model="params.startTime"  class="form-control calendars" format="yyyy-mm-dd" v-bind:start-date="params.startTime">
				  	<span class="input-group-addon">
					<i class="glyphicon glyphicon-calendar"></i>
					</span>
				</div>
			</div>
			<input type="hidden" id='tmpStartDateVal' value="">
			<div class="col-xs-5 col-md-2" style="width: 33%;">
				<div class="input-group">
					<input type="text" id="end-date" onchange="checkNewDate(2)" v-model="params.endTime" class="form-control calendars" format="yyyy-mm-dd" v-bind:start-date="params.endTime">
				  	<span class="input-group-addon">
					<i class="glyphicon glyphicon-calendar"></i>
					</span>
				</div>
			</div>

			<div class="col-xs-1 col-md-1">
				<button style="background-color:#4aa4fc;border: 1px solid #4aa4fc;"  type="button" class="btn btn-primary" v-on:click="getGlucometerData">确定</button>
			</div>
		</div>
		<div id="iechart" v-bind:style="myStyle"></div>
	</div>
	<script type="text/javascript" src="assets/js/main.js?v=1.23"></script>
	<!--<script src="assets/js/hor.js"></script>-->
	<p class="cshow" style="display: none;"></p>
</body>
</html>
